// 1. 获取所有需要操作的DOM元素
const openSidebarBtn = document.getElementById('openSidebar');
const closeSidebarBtn = document.getElementById('closeSidebar');
const sidebar = document.getElementById('sidebar');
const overlay = document.getElementById('overlay');

// 2. 打开侧边栏：添加激活类
function openSidebar() {
    sidebar.classList.add('open');
    overlay.classList.add('active');
}

// 3. 关闭侧边栏：移除激活类
function closeSidebar() {
    sidebar.classList.remove('open');
    overlay.classList.remove('active');
}

// 4. 绑定点击事件
openSidebarBtn.addEventListener('click', openSidebar);
closeSidebarBtn.addEventListener('click', closeSidebar);
overlay.addEventListener('click', closeSidebar); // 点击外部遮罩关闭